{% extends "base.html" %}
{% load static %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card">
                <div class="card-header">
                    <h4 class="mb-0">用户注册</h4>
                </div>
                <div class="card-body">
                    <form method="post" class="needs-validation" novalidate>
                        {% csrf_token %}
                        
                        {% if form.errors %}
                        <div class="alert alert-danger">
                            {% for field in form %}
                                {% for error in field.errors %}
                                    <p class="mb-0">{{ field.label }}: {{ error }}</p>
                                {% endfor %}
                            {% endfor %}
                        </div>
                        {% endif %}
                        
                        <div class="mb-3">
                            <label for="{{ form.username.id_for_label }}" class="form-label">工号</label>
                            {{ form.username }}
                            {% if form.username.help_text %}
                            <div class="form-text">{{ form.username.help_text }}</div>
                            {% endif %}
                        </div>
                        <div class="mb-3">
                            <label for="{{ form.first_name.id_for_label }}" class="form-label">用户名</label>
                            {{ form.first_name }}
                            {% if form.first_name.help_text %}
                            <div class="form-text">{{ form.first_name.help_text }}</div>
                            {% endif %}
                        </div>
                        <div class="mb-3">
                            <label for="{{ form.email.id_for_label }}" class="form-label">电子邮箱</label>
                            {{ form.email }}
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.password1.id_for_label }}" class="form-label">密码</label>
                            {{ form.password1 }}
                            {% if form.password1.help_text %}
                            <div class="form-text">{{ form.password1.help_text }}</div>
                            {% endif %}
                        </div>
                        
                        <div class="mb-3">
                            <label for="{{ form.password2.id_for_label }}" class="form-label">确认密码</label>
                            {{ form.password2 }}
                        </div>
                        
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary">注册</button>
                            <a href="{% url 'login' %}" class="btn btn-outline-secondary">返回登录</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 